package dt.member;

import com.opensymphony.xwork2.ActionSupport;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import java.io.IOException;
import java.io.Reader;

public class memberNickCheckAction extends ActionSupport {
	
	public static Reader reader;  // ���� ��Ʈ���� ���� reader
	public static SqlMapClient sqlMapper; // SqlMapClient API�� ����ϱ� ���� sqlMapper ��ü
	
	private memberVO paramClass; //�Ķ���͸� ������ ��ü
	private memberVO resultClass; //���� ��� ���� ������ ��ü
	
	private String nickname;
	private int chkNick;
	
	// ����
	public memberNickCheckAction() throws IOException {
		reader = Resources.getResourceAsReader("sqlMapConfig.xml"); //sqlMapConfig.xml ������ ���������� �����´�.
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader); //sqlMapConfig.xml ������ ����� sqlMapper ��ü ��
		reader.close();
	}
	
	// nickname check �׼�
	public String execute() throws Exception {
		resultClass = (memberVO) sqlMapper.queryForObject("nickCheck", getNickname());
		if(resultClass == null) {
			chkNick = 0; // ��밡���� �г���
		}
		else {
			chkNick = 1; // ���Ұ��� �г���
		}
	
		return SUCCESS;
		
	}

	public static Reader getReader() {
		return reader;
	}

	public static void setReader(Reader reader) {
		memberNickCheckAction.reader = reader;
	}

	public static SqlMapClient getSqlMapper() {
		return sqlMapper;
	}

	public static void setSqlMapper(SqlMapClient sqlMapper) {
		memberNickCheckAction.sqlMapper = sqlMapper;
	}

	public memberVO getParamClass() {
		return paramClass;
	}

	public void setParamClass(memberVO paramClass) {
		this.paramClass = paramClass;
	}

	public memberVO getResultClass() {
		return resultClass;
	}

	public void setResultClass(memberVO resultClass) {
		this.resultClass = resultClass;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public int getChkNick() {
		return chkNick;
	}

	public void setChkNick(int chkNick) {
		this.chkNick = chkNick;
	}
	

}
